﻿using MediatR;
using Traceability.Commont.Domains.ScratchTheFat;
using Traceability.Commont.DTOs.CommontFiles;
using Traceability.Commont.Infrastructures.Interfaces;
namespace U.Enterprise.Api.Applications.PartitionWarehousings
{
    public class SplitRUDelHandler:IRequestHandler<SplitRUDelCommond, Resqults>
    {

        private readonly IBateRepository<SplitRU> _SplitRU;

        public SplitRUDelHandler(IBateRepository<SplitRU> splitRU
            )
        {
            _SplitRU = splitRU;
        }

        public async Task<Resqults> Handle(SplitRUDelCommond request, CancellationToken cancellationToken)
        {
            

            var list=new Resqults() { Code=0};

            var query = _SplitRU.GetAll().FirstOrDefault(x => x.SplitWarehousingId == request.SplitWarehousingId);

            if(query!=null)
            {
                query.Stoct = 1;
              var result=await _SplitRU.Update(query);

                if(result!=null)
                {
                    list.Code = 1;
                }
                
            }

            return list;

        }
    }
}
